<?php

/**
 * @name: HOTN Scroller
 * @author: HammerOnTheNail
 * @link: http://code.google.com/p/hotnscroller/
 */

$title .= " / ".HOTN_SCROLLER_ADMIN_MENU_ITTEM_LIST;

if ($qs[2] == "action" && $qs[3] <> "")
{
	$sql->db_Select("hotn_scroller_ittems","*","`ittems_id` = '".(int)$qs[3]."'");
	$row = $sql->db_Fetch();
	
	// Form összeillesztése
	$data = array(
		"type" => "file_form",
		"method" => "post",
		"action" =>  e_PLUGIN ."hotn_scroller/admin/admin_action.php",
		"hidden" => array(
							"action" => "edit",
							"id" => $qs[3]
					),
		"data" => array(
					array(
						"type" => "text",
						"name" => "title",
						"value" => $row['ittems_title'],
						"text" => HOTN_SCROLLER_ADMIN_ITTEM_TABLE_TITLE
					),
					array(
						"type" => "textarea",
						"name" => "text",
						"bbcode" => TRUE,
						"value" => $row['ittems_text'],
						"text" => HOTN_SCROLLER_ADMIN_ITTEM_TABLE_TEXT
					),
					array(
						"type" => "text",
						"name" => "link",
						"value" => $row['ittems_link'],
						"text" => HOTN_SCROLLER_ADMIN_ITTEM_TABLE_LINK
					),
					array(
						"type" => "text",
						"name" => "link_type",
						"value" => $row['ittems_link_type'],
						"text" => HOTN_SCROLLER_ADMIN_ITTEM_TABLE_LINK_TYPE
					),
					array(
						"type" => "image",
						"name" => "file_userfile[]",
						"image_name" => "file_userfile",
						"value" => e_PLUGIN."hotn_scroller/images/".$row['ittems_image'],
						"text" => HOTN_SCROLLER_ADMIN_ITTEM_TABLE_IMAGE
					),
					array(
						"type" => "submit",
						"value" => HOTN_SCROLLER_ADMIN_ITTEM_TABLE_SUBMIT
					)
				)
	);
	
	// Form megjelenítése
	$text = $HOTN_SCROLLER_FORM->show_form($data);
}
else
{
	if ($sql->db_Select("hotn_scroller_ittems","*","ORDER BY ittems_order ASC","non-default")<>0)
	{
		$text = "
			<form action='".e_PLUGIN."hotn_scroller/admin/admin_action.php' method='get'>
			<input type='hidden' name='action' value='delete' />
				<table class='fborder' width='95%'>
					<tr>
						<td class='fcaption'>
							".HOTN_SCROLLER_ADMIN_ITTEMS_TABLE_NAME."
						</td>
						<td class='fcaption' style='width:150px;'>
							".HOTN_SCROLLER_ADMIN_ITTEMS_TABLE_IMAGE."
						</td>
						<td class='fcaption' style='width:150px;'>
							".HOTN_SCROLLER_ADMIN_ITTEMS_TABLE_OPTIONS."
						</td>
					</tr>
		";
		
		while($row = $sql->db_Fetch())
		{
			if ($row['ittems_image'] <> "") $row['ittems_image'] = "<img src='".e_PLUGIN."hotn_scroller/images/".$row['ittems_image']."' Width='100' />";
			
			$text .= "
				<tr>
					<td class='forumheader3'>
						<a href='".e_PLUGIN."hotn_scroller/admin/admin_index.php?ittem.list.action.".$row['ittems_id']."'>".$row['ittems_title']."</a>
					</td>
					<td class='forumheader3' style='text-align: center;'>
						".$row['ittems_image']."
					</td>
					<td class='forumheader3' style='text-align: center;'>
						<a href='".e_PLUGIN."hotn_scroller/admin/admin_action.php?action=ittem_up&id=".$row['ittems_id']."'><img src='".e_IMAGE."admin_images/up.png' /></a>
						<a href='".e_PLUGIN."hotn_scroller/admin/admin_action.php?action=ittem_down&id=".$row['ittems_id']."'><img src='".e_IMAGE."admin_images/down.png' /></a>
						<input type='checkbox' class='tbox' name='id[]' value='".$row['ittems_id']."' /> ".HOTN_SCROLLER_ADMIN_ITTEMS_TABLE_CHECKBOX."
					</td>
				</tr>
			";
		}
		
		$text .= "
					<tr>
						<td colspan='3' class='forumheader' style='text-align:center;'>
							<input type='submit' class='button' value='".HOTN_SCROLLER_ADMIN_ITTEM_TABLE_DELETE."' />
						</td>
					<tr>
				</table>
			</form>
		";
	}
	else
	{
		$text = HOTN_SCROLLER_ADMIN_ITTEM_NO_ITTEM;
	}
}

$text = "<div style='text-align: center;'>".$text."</div>";
?>